
package GuiBencinera;

import bencinera.*;
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

public class GUIBEN extends javax.swing.JFrame {
     Bencinera2 b= new Bencinera2();
    /**
     * Creates new form GUIBEN
     */
    public GUIBEN() {
        initComponents();
    }

    
    
    
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroupTipoBencina = new javax.swing.ButtonGroup();
        jDesktopPane1 = new javax.swing.JDesktopPane();
        jInternalFrameingresarventa = new javax.swing.JInternalFrame();
        jLbllitroscompra = new javax.swing.JLabel();
        jLblmontoventa = new javax.swing.JLabel();
        jLblseleccionecombustible = new javax.swing.JLabel();
        jTxtmontoventa = new javax.swing.JTextField();
        jTxtlitroscompra = new javax.swing.JTextField();
        jRbtn93oct = new javax.swing.JRadioButton();
        jRbtn95oct = new javax.swing.JRadioButton();
        jRbtn97oct = new javax.swing.JRadioButton();
        jRbtndiesel = new javax.swing.JRadioButton();
        jBtnregistrar = new javax.swing.JButton();
        jBtnlimpiar = new javax.swing.JButton();
        jInternalFrameresumen = new javax.swing.JInternalFrame();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTblventasrealizadas = new javax.swing.JTable();
        jLblventasrealizadas = new javax.swing.JLabel();
        jLbllitrosvendidos = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLblTotalventas = new javax.swing.JLabel();
        jTxtTotalventas = new javax.swing.JTextField();
        jBtnactualizar = new javax.swing.JButton();
        jTxtlitros93 = new javax.swing.JTextField();
        jTxtlitros95 = new javax.swing.JTextField();
        jTxtlitros97 = new javax.swing.JTextField();
        jTxtlitrosdiesel = new javax.swing.JTextField();
        jTxtTotal = new javax.swing.JTextField();
        jInternalFrameacercade = new javax.swing.JInternalFrame();
        jTextField2 = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenuarchivo = new javax.swing.JMenu();
        jMenuItemsalir = new javax.swing.JMenuItem();
        jMenuventas = new javax.swing.JMenu();
        jMenuItemregistrarventa = new javax.swing.JMenuItem();
        jMenuItemresumendia = new javax.swing.JMenuItem();
        jMenuayuda = new javax.swing.JMenu();
        jMenuItemacercade = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });

        jDesktopPane1.setBackground(new java.awt.Color(240, 240, 240));

        jInternalFrameingresarventa.setClosable(true);
        jInternalFrameingresarventa.setTitle("Ingresar Venta");
        jInternalFrameingresarventa.setVisible(true);

        jLbllitroscompra.setText("Litros por esta compra");

        jLblmontoventa.setText("Ingrese monto venta $");

        jLblseleccionecombustible.setText("Seleccione combustible:");

        jTxtlitroscompra.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTxtlitroscompraActionPerformed(evt);
            }
        });

        buttonGroupTipoBencina.add(jRbtn93oct);
        jRbtn93oct.setText("93 octanos");

        buttonGroupTipoBencina.add(jRbtn95oct);
        jRbtn95oct.setText("95 octanos");
        jRbtn95oct.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRbtn95octActionPerformed(evt);
            }
        });

        buttonGroupTipoBencina.add(jRbtn97oct);
        jRbtn97oct.setText("97 octanos");

        buttonGroupTipoBencina.add(jRbtndiesel);
        jRbtndiesel.setText("Diesel");

        jBtnregistrar.setText("Registrar");
        jBtnregistrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnregistrarActionPerformed(evt);
            }
        });

        jBtnlimpiar.setText("Limpiar");
        jBtnlimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnlimpiarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jInternalFrameingresarventaLayout = new javax.swing.GroupLayout(jInternalFrameingresarventa.getContentPane());
        jInternalFrameingresarventa.getContentPane().setLayout(jInternalFrameingresarventaLayout);
        jInternalFrameingresarventaLayout.setHorizontalGroup(
            jInternalFrameingresarventaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrameingresarventaLayout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(jInternalFrameingresarventaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jInternalFrameingresarventaLayout.createSequentialGroup()
                        .addComponent(jLblseleccionecombustible)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jInternalFrameingresarventaLayout.createSequentialGroup()
                        .addGroup(jInternalFrameingresarventaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jRbtndiesel)
                            .addGroup(jInternalFrameingresarventaLayout.createSequentialGroup()
                                .addGroup(jInternalFrameingresarventaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLbllitroscompra)
                                    .addComponent(jLblmontoventa))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jInternalFrameingresarventaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jTxtlitroscompra, javax.swing.GroupLayout.DEFAULT_SIZE, 131, Short.MAX_VALUE)
                                    .addComponent(jTxtmontoventa))))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jInternalFrameingresarventaLayout.createSequentialGroup()
                        .addGroup(jInternalFrameingresarventaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jRbtn97oct)
                            .addComponent(jRbtn93oct)
                            .addComponent(jRbtn95oct))
                        .addGap(56, 56, 56)
                        .addGroup(jInternalFrameingresarventaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jBtnlimpiar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jBtnregistrar, javax.swing.GroupLayout.DEFAULT_SIZE, 108, Short.MAX_VALUE))
                        .addGap(36, 36, 36))))
        );
        jInternalFrameingresarventaLayout.setVerticalGroup(
            jInternalFrameingresarventaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrameingresarventaLayout.createSequentialGroup()
                .addGroup(jInternalFrameingresarventaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jInternalFrameingresarventaLayout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(jLblseleccionecombustible)
                        .addGap(8, 8, 8)
                        .addComponent(jRbtn93oct)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRbtn95oct)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRbtn97oct)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRbtndiesel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE))
                    .addGroup(jInternalFrameingresarventaLayout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jBtnregistrar)
                        .addGap(18, 18, 18)
                        .addComponent(jBtnlimpiar)
                        .addGap(29, 29, 29)))
                .addGroup(jInternalFrameingresarventaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLblmontoventa)
                    .addComponent(jTxtmontoventa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(29, 29, 29)
                .addGroup(jInternalFrameingresarventaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLbllitroscompra)
                    .addComponent(jTxtlitroscompra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(47, 47, 47))
        );

        jInternalFrameingresarventa.setBounds(20, 20, 320, 290);
        jDesktopPane1.add(jInternalFrameingresarventa, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jInternalFrameresumen.setClosable(true);
        jInternalFrameresumen.setTitle("Resumen");
        jInternalFrameresumen.setAlignmentY(1.0F);
        jInternalFrameresumen.setVisible(true);

        jTblventasrealizadas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Tipo", "Litros", "Total"
            }
        ));
        jTblventasrealizadas.setRowHeight(30);
        jTblventasrealizadas.setSelectionBackground(new java.awt.Color(240, 240, 240));
        jTblventasrealizadas.setSelectionForeground(new java.awt.Color(240, 240, 240));
        jScrollPane1.setViewportView(jTblventasrealizadas);

        jLblventasrealizadas.setText("Ventas Realizadas:");

        jLbllitrosvendidos.setText("Cantidad litros Vendidos:");

        jLabel3.setText("93");

        jLabel4.setText("95");

        jLabel5.setText("97");

        jLabel6.setText("Diesel");

        jLabel7.setText("TOTAL");

        jLblTotalventas.setText("TOTAL VENTAS $");

        jBtnactualizar.setText("Actualizar");
        jBtnactualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnactualizarActionPerformed(evt);
            }
        });

        jTxtlitros95.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTxtlitros95ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jInternalFrameresumenLayout = new javax.swing.GroupLayout(jInternalFrameresumen.getContentPane());
        jInternalFrameresumen.getContentPane().setLayout(jInternalFrameresumenLayout);
        jInternalFrameresumenLayout.setHorizontalGroup(
            jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrameresumenLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(jInternalFrameresumenLayout.createSequentialGroup()
                        .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLblventasrealizadas)
                            .addGroup(jInternalFrameresumenLayout.createSequentialGroup()
                                .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel6))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTxtlitrosdiesel, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jTxtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jInternalFrameresumenLayout.createSequentialGroup()
                        .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(jInternalFrameresumenLayout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jTxtlitros97, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jInternalFrameresumenLayout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jTxtlitros95, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jInternalFrameresumenLayout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jTxtlitros93, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLbllitrosvendidos, javax.swing.GroupLayout.Alignment.LEADING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 81, Short.MAX_VALUE)
                        .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLblTotalventas, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jBtnactualizar, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
                                .addComponent(jTxtTotalventas)))))
                .addContainerGap())
        );
        jInternalFrameresumenLayout.setVerticalGroup(
            jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrameresumenLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLblventasrealizadas)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(38, 38, 38)
                .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLbllitrosvendidos)
                    .addComponent(jLblTotalventas))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTxtTotalventas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTxtlitros93, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jInternalFrameresumenLayout.createSequentialGroup()
                        .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTxtlitros95, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addGap(15, 15, 15)
                        .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jTxtlitros97, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jBtnactualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTxtlitrosdiesel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addGap(15, 15, 15)
                .addGroup(jInternalFrameresumenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTxtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addContainerGap(48, Short.MAX_VALUE))
        );

        jInternalFrameresumen.setBounds(350, 20, 400, 490);
        jDesktopPane1.add(jInternalFrameresumen, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jInternalFrameacercade.setClosable(true);
        jInternalFrameacercade.setTitle("Acerca de...");
        jInternalFrameacercade.setVisible(true);

        jLabel9.setText("Informacion Personal");

        javax.swing.GroupLayout jInternalFrameacercadeLayout = new javax.swing.GroupLayout(jInternalFrameacercade.getContentPane());
        jInternalFrameacercade.getContentPane().setLayout(jInternalFrameacercadeLayout);
        jInternalFrameacercadeLayout.setHorizontalGroup(
            jInternalFrameacercadeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jInternalFrameacercadeLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26))
        );
        jInternalFrameacercadeLayout.setVerticalGroup(
            jInternalFrameacercadeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jInternalFrameacercadeLayout.createSequentialGroup()
                .addGroup(jInternalFrameacercadeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jInternalFrameacercadeLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jInternalFrameacercadeLayout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addComponent(jLabel9)))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        jInternalFrameacercade.setBounds(20, 330, 320, 160);
        jDesktopPane1.add(jInternalFrameacercade, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jMenuarchivo.setText("Archivo");

        jMenuItemsalir.setText("Salir");
        jMenuItemsalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemsalirActionPerformed(evt);
            }
        });
        jMenuarchivo.add(jMenuItemsalir);

        jMenuBar1.add(jMenuarchivo);

        jMenuventas.setText("Ventas");

        jMenuItemregistrarventa.setText("Registrar Venta");
        jMenuItemregistrarventa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemregistrarventaActionPerformed(evt);
            }
        });
        jMenuventas.add(jMenuItemregistrarventa);

        jMenuItemresumendia.setText("Resumen del dia");
        jMenuItemresumendia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemresumendiaActionPerformed(evt);
            }
        });
        jMenuventas.add(jMenuItemresumendia);

        jMenuBar1.add(jMenuventas);

        jMenuayuda.setText("Ayuda");

        jMenuItemacercade.setText("Acerca de...");
        jMenuItemacercade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemacercadeActionPerformed(evt);
            }
        });
        jMenuayuda.add(jMenuItemacercade);

        jMenuBar1.add(jMenuayuda);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 793, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 524, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTxtlitroscompraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTxtlitroscompraActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTxtlitroscompraActionPerformed

    private void jTxtlitros95ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTxtlitros95ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTxtlitros95ActionPerformed

    private void jMenuItemregistrarventaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemregistrarventaActionPerformed
        this.jInternalFrameingresarventa.setVisible(true);
    }//GEN-LAST:event_jMenuItemregistrarventaActionPerformed

    private void jMenuItemresumendiaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemresumendiaActionPerformed
        this.jInternalFrameresumen.setVisible(true);
    }//GEN-LAST:event_jMenuItemresumendiaActionPerformed

    private void jMenuItemacercadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemacercadeActionPerformed
        this.jInternalFrameacercade.setVisible(true);
    }//GEN-LAST:event_jMenuItemacercadeActionPerformed

    private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
     
    }//GEN-LAST:event_formComponentShown

    private void jMenuItemsalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemsalirActionPerformed
        this.dispose();
    }//GEN-LAST:event_jMenuItemsalirActionPerformed

    private void jBtnlimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnlimpiarActionPerformed
        limpiarRegistro();
    }//GEN-LAST:event_jBtnlimpiarActionPerformed

    private void jBtnregistrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnregistrarActionPerformed
        ingresarVenta();
    }//GEN-LAST:event_jBtnregistrarActionPerformed

    private void jBtnactualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnactualizarActionPerformed
       actualizar();
    }//GEN-LAST:event_jBtnactualizarActionPerformed

    private void jRbtn95octActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRbtn95octActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jRbtn95octActionPerformed

private void ingresarVenta(){

   String tipo="";
        if(this.jRbtn93oct.isSelected()){
          tipo="93";
        }
        if(this.jRbtn95oct.isSelected()){
          tipo= "95";
        }
        if(this.jRbtn97oct.isSelected()){
          tipo= "97";
        }
        if(this.jRbtndiesel.isSelected()){
          tipo="diesel";
        }
        
        int total= Integer.parseInt(this.jTxtmontoventa.getText());
        
        double litros=0;
        if (this.jRbtn93oct.isSelected()){
            litros = (double) total/717;
            DecimalFormat x=new DecimalFormat("#,###.##");
            
           this.jTxtlitroscompra.setText(""+x.format(litros));
        }
        if(this.jRbtn95oct.isSelected()){
            litros = (double)total/739;
           DecimalFormat x=new DecimalFormat("#,###.##");
            
           this.jTxtlitroscompra.setText(""+x.format(litros));
        
        }
        if(this.jRbtn97oct.isSelected()){
            litros = (double) total/754;
             DecimalFormat x=new DecimalFormat("#,###.##");
            
           this.jTxtlitroscompra.setText(""+x.format(litros));
        }
        if(this.jRbtndiesel.isSelected()){
            litros = (double) total/567;
            DecimalFormat x=new DecimalFormat("#,###.##");
            
            this.jTxtlitroscompra.setText(""+x.format(litros));
        }
               
              
             
        
       Venta v= new Venta(tipo,litros,total);
       if( b.ingresarVenta(v)){
       JOptionPane.showMessageDialog(null,"Ingreso satisfactorio", "Aguita pal toco", JOptionPane.INFORMATION_MESSAGE);
       }
       else{
       JOptionPane.showMessageDialog(null,"Ingreso erroneo", "Aguita pal toco", JOptionPane.ERROR_MESSAGE);
       }
        limpiarRegistro();
        cargarListadoventa();

}
   
   
    
    private void limpiarRegistro(){
    
        this.jTxtlitroscompra.setText(null);
        this.jTxtmontoventa.setText(null);
        this.jRbtn93oct.setSelected(true);
        this.jRbtn95oct.setSelected(false);
        this.jRbtn97oct.setSelected(false);
        this.jRbtndiesel.setSelected(false);
      }
    
    private void cargarListadoventa(){
        DefaultTableModel listado = new DefaultTableModel();
        listado.addColumn("tipo");
        listado.addColumn("litros");
        listado.addColumn("total");
        
        
        for(Venta v: b.getVentas())
        {
            Object[] fila = new Object[3];
            fila[0] = v.getTipo();
            fila[1] = v.getLitros();
            fila[2] = v.getTotal();
            
          
            listado.addRow(fila);
        }
        this.jTblventasrealizadas.setModel(listado);
    }
    
    private void actualizar(){
    
    cargarListadoventa();
    
    this.jTxtlitros93.setText(""+b.litrosVendidos("93"));
    this.jTxtlitros95.setText(""+b.litrosVendidos("95"));
    this.jTxtlitros97.setText(""+b.litrosVendidos("97"));
    this.jTxtlitrosdiesel.setText(""+b.litrosVendidos("diesel"));
    this.jTxtTotalventas.setText(""+b.totalVentas());
    
    
    
    
    
    }
    
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(GUIBEN.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(GUIBEN.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(GUIBEN.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(GUIBEN.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new GUIBEN().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroupTipoBencina;
    private javax.swing.JButton jBtnactualizar;
    private javax.swing.JButton jBtnlimpiar;
    private javax.swing.JButton jBtnregistrar;
    private javax.swing.JDesktopPane jDesktopPane1;
    private javax.swing.JInternalFrame jInternalFrameacercade;
    private javax.swing.JInternalFrame jInternalFrameingresarventa;
    private javax.swing.JInternalFrame jInternalFrameresumen;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLblTotalventas;
    private javax.swing.JLabel jLbllitroscompra;
    private javax.swing.JLabel jLbllitrosvendidos;
    private javax.swing.JLabel jLblmontoventa;
    private javax.swing.JLabel jLblseleccionecombustible;
    private javax.swing.JLabel jLblventasrealizadas;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItemacercade;
    private javax.swing.JMenuItem jMenuItemregistrarventa;
    private javax.swing.JMenuItem jMenuItemresumendia;
    private javax.swing.JMenuItem jMenuItemsalir;
    private javax.swing.JMenu jMenuarchivo;
    private javax.swing.JMenu jMenuayuda;
    private javax.swing.JMenu jMenuventas;
    private javax.swing.JRadioButton jRbtn93oct;
    private javax.swing.JRadioButton jRbtn95oct;
    private javax.swing.JRadioButton jRbtn97oct;
    private javax.swing.JRadioButton jRbtndiesel;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTblventasrealizadas;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTxtTotal;
    private javax.swing.JTextField jTxtTotalventas;
    private javax.swing.JTextField jTxtlitros93;
    private javax.swing.JTextField jTxtlitros95;
    private javax.swing.JTextField jTxtlitros97;
    private javax.swing.JTextField jTxtlitroscompra;
    private javax.swing.JTextField jTxtlitrosdiesel;
    private javax.swing.JTextField jTxtmontoventa;
    // End of variables declaration//GEN-END:variables
}
